<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="./vue.js"></script>
</head>
<body>
  <template id="hello">
    <div>
      <slot name="s1"></slot>
      <h3>{{title}}</h3>
      <!-- 插槽：在定义子组件的时候预留一个插槽，使用子组件的时候可以传递html结构进来 -->
      <!-- 单插槽不需要写name，直接插入即可，但是多插槽的话需要给每个插槽写上name属性，插入标签的时候写上slot属性，跟插槽的name对应 -->
      <slot name="s2"></slot>
    </div>
  </template>
  <div id="app">
    <hello-world :title="title">
      <p slot="s1">content</p>
      <p slot="s2">content2</p>
    </hello-world>

    <hello-world :title="title">
      <son slot="s1"></son>
    </hello-world>
  </div>
  <script>
    const helloWorld = {
      template: '#hello',
      props: ['title', 'content']
    }

    const son = {
      template: '<b>son</b>'
    }


    const app = new Vue({
      el: '#app',
      data: {
        title: 'hello 1912'
      },
      components: {
        helloWorld,
        son
      }
    })
  </script>
</body>
</html>
